package com.example.test.controller;

import com.example.test.dto.Result;
import com.example.test.entity.Weather;
import com.example.test.repo.Weather1Repository;
import com.example.test.repo.WeatherRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 日期：2022/11/5
 * 作者：flag
 * 功能：默认控制器
 */
@RestController
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
public class WeatherController {

    @Autowired
    WeatherRepository weatherRepository;

    @Autowired
    Weather1Repository weather1Repository;

    @RequestMapping("/weather")
    public Result findAll() {
        List<Map> weatherMinMaxTmp = weatherRepository.getWeatherMinMaxTmp();
        return Result.success(weatherMinMaxTmp);
    }

    @RequestMapping("/weather1")
    public Result getWeatherMaxTmp() {
        List<Map> weatherMaxTmp = weather1Repository.getWeatherMaxTmp();
        return Result.success(weatherMaxTmp);
    }
}
